#include "commonuse.h"
//预定义

// int main()
// {
//     printf("%s\n",__FILE__);
//     //predefined symbols represent symnols that are already defined in C programing language
//     //"__FILE__"represent the current file's address
//     printf("%d\n", __LINE__);
//     //"__LINE__"represent the line of this "__LINE__"
//     printf("%s\n",__DATE__);
//     //"__DATE__"is the day when the code be functioned
//     for(int a=0;a<10;a++)
//     {
//         Sleep(1000);
//         printf("%s\n",__TIME__);
//     }
//     //"__TIME__" can accurate to seconds
//     //after testing，wef found that the record time by 
//     //the __TIEM__ and __DATE__,is the time when the program
//     //begin to run
//     system("pause");
//     return 0;
// }


//Instructions starting with # are preprocessing instruction


//like #include ,#define

//#define
//generally ,you don't have to plus semicolon follow the  defined content

//macro(宏)
//#define macoro(parameter) stuff
//example
// #define squre(x) x*x
// int main()
// {
//     printf("%d\n",squre(5+1));
//     system("pause");
//     return 0;
// }
//the reason of the result of the printf is
//macoro will only replace the original parameter ,
//instead of passing values
//example:answer here is 5+1*5+1,so we get 11
//therefore we should braket the paremeter like (x)
//example:(x)*(x)


//example 2
// #define double(x) x+x
// int main()
// {
//     printf("%d\n", 10*double(5));
//     system("pause");
//     return 0;
// }

//the same reason the macro is purely replace

//the rule of #difine 
//1.we can use the string defined by "#defined" in the macro
//2.also,the string will be replaced before the macro is replaced
//3.recursion can't be used in macro
//4.the string defined by #defined in the "Double Quotes" won't be replaced




//# and ##

// #define lianhe(x, y) x##y

// int main()
// {
//     int c12 = 0;
//     printf("%d\n", lianhe(c, 12));

//     system("pause");
//     return 0;
// }

//the role of ## is used for connecting the string into a new string
//the new string is as a new pare varial name 
//the example is as above


// #define SZ(type) sizeof(type)
// // the macro is used to replace the function in this way will be better
// //关于宏整体定义的理解，首先是单纯的替换而已，穿的表达式也只是依照后面的执行
// //example：如果带有括号，其实也就是这个宏相当于是一个函数类型的，需要传参
// //什么意思呢，就是SZ是我们的宏，而type是宏的参数，后面就是整个宏该如何替换
// //参数就用括号内的参数，将后面的对应参数成分替换
// //这里的sizeof就是，全部的sizeof(type)表示宏，里面的值就是宏的参数来替换
// //最后得到替换后的值
// #define MALLOC(type,size) (type*)malloc(size*sizeof(type))
// //here is an example by malloc
// int main()
// {
//     printf("%d\n",SZ(int));
//     char *p = MALLOC(char,10);
//     //this way ,we will be more convenient than use directly malloc function 
//     free(p);p=NULL;
//     system("pause");
//     return 0;
// }

#define debug

// int main()
// {
//     //ifno string "debug" is defined ,then the sentence will not be implemented

// #ifdef debug
//     printf("qwe2d\n");
// #endif
// #if 1 //if the sentence following #ifdef is false ,then the sentence between if ad endif will not be implemented
//     printf("qwe2d\n");
// #endif

// //multi branch stateent
// #if 0
// #elif 0
// #elif 0
// #else
// #endif
//     system("pause");
//     return 0;
// }

// int main()
// {
// #if !defined(debug)
//     system("pause");
// #endif
//     return 0;
// }
// //above ,we can use the this to get opposed effect "#ifdef" and "#if defined"



// #define OFFSET(structname,member)  (int)(&(((structname*)0)->member))
// //这里编译器报警告，指针类型转换为整形
// //计算结构体成员的偏移量，即转换为地址来计算，因为直接首地址就默认为0，所以直接地址进行整形转换即可sq
// struct s
// {
//     char a;
//     int b;
//     char c;
// };
// int main()
// {
//     printf("%d\n", OFFSET(struct s,c));
//     system("pause");
//     return 0;
// }
